package com.tianjin.design.composite;

import java.util.ArrayList;

public abstract class CompanyComponent {

	protected String name; // 节点名称
	public void setName(String name) {
		this.name = name;
	}
	public String getName() {
		return name;
	}
	
	protected ArrayList<CompanyComponent> children = new ArrayList<CompanyComponent>();
	public void setChildren(ArrayList<CompanyComponent> children) {
		this.children = children;
	}
	public ArrayList<CompanyComponent> getChildren() {
		return children;
	}
	
	@Override
	public String toString() {
		
		System.out.println(name);
		for(int i=0; i< children.size();i++) {
			System.out.println(children.get(i).getName());
		}
		return "";
	}
	
	abstract void display(int depth);
	abstract void add(CompanyComponent component);
	abstract void remove(CompanyComponent component);
	
}
